home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / gtlayout-source.lha / LTP_GetDisplayClip.c < prev    next >
C/C++ Source or Header  |  1995-09-24  |  1KB  |  61 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. VOID __regargs
  10. LTP_GetDisplayClip(struct Screen *screen,WORD *left,WORD *top,WORD *width,WORD *height)
  11. {
  12.     struct TagItem tags[2] = { VTAG_VIEWPORTEXTRA_GET, NULL, TAG_DONE };
  13.  
  14.     if(!VideoControl(screen -> ViewPort . ColorMap,tags))
  15.     {
  16.         struct ViewPortExtra    *vpe = (struct ViewPortExtra *)tags[0] . ti_Data;
  17.         struct Rectangle         clip;
  18.  
  19.         QueryOverscan(GetVPModeID(&screen -> ViewPort),&clip,OSCAN_TEXT);
  20.  
  21.         *width    = vpe -> DisplayClip . MaxX - vpe -> DisplayClip . MinX + 1;
  22.         *height = vpe -> DisplayClip . MaxY - vpe -> DisplayClip . MinY + 1;
  23.  
  24.         if(*width < clip . MaxX - clip . MinX + 1)
  25.             *width = clip . MaxX - clip . MinX + 1;
  26.  
  27.         if(*height < clip . MaxY - clip . MinY + 1)
  28.             *height = clip . MaxY - clip . MinY + 1;
  29.  
  30.         if(*width > screen -> Width)
  31.             *width = screen -> Width;
  32.  
  33.         if(*height > screen -> Height)
  34.             *height = screen -> Height;
  35.     }
  36.     else
  37.     {
  38.         *width    = screen -> Width;
  39.         *height = screen -> Height;
  40.     }
  41.  
  42.     *left = screen -> LeftEdge;
  43.     *top  = screen -> TopEdge;
  44.  
  45.     if(*left > 0)
  46.         *left = 0;
  47.     else
  48.         *left = -(*left);
  49.  
  50.     if(*top > 0)
  51.         *top = 0;
  52.     else
  53.         *top = -(*top);
  54.  
  55.     if((*left > screen -> Width) || (*left < 0))
  56.         *left = 0;
  57.  
  58.     if ((*top > screen -> Height) || (*top < 0))
  59.         *top = 0;
  60. }
  61.